/**
 * @Author: wangliuyang
 * @Date: 2021/8/17 21:18
 * @Description:
 */
public class Solution_122 {
    public int maxProfit(int[] prices) {
        int ans = 0;
        int pre = prices[0];
        for (int i = 0; i < prices.length; i++) {
            if (prices[i] > pre) {
                ans += prices[i] - pre;
            }
            pre = prices[i];
        }
        return ans;
    }
}
